#!/bin/sh
# cluster_ssh_key
# cluster_ssh_pub_key
# username

sed -i '/StrictHostKeyChecking/c StrictHostKeyChecking no' /etc/ssh/ssh_config

umask 0077
echo "$cluster_ssh_key" > /root/.ssh/id_rsa
echo "$cluster_ssh_pub_key" > /root/.ssh/id_rsa.pub
echo "$cluster_ssh_pub_key" >> /root/.ssh/authorized_keys

[[ -n $username ]] || exit 0
echo "$cluster_ssh_key" > /home/$username/.ssh/id_rsa
echo "$cluster_ssh_pub_key" > /home/$username/.ssh/id_rsa.pub
echo "$cluster_ssh_pub_key" >> /home/$username/.ssh/authorized_keys

chown -R $username:$username /home/$username/.ssh
